﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;

using ZoneFiveSoftware.Common.Data;
using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Data.GPS;

using BENBUN.Properties;
using BENBUN.Utils;

namespace BENBUN.UI.Forms
{
    public partial class LoadMultipleConfirmation : Form
    {
        public IList<IActivity> activities;

        public LoadMultipleConfirmation()
        {
            InitializeComponent();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void LoadMultipleConfirmation_Shown(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            progressBar1.Maximum = activities.Count;
            progressBar1.Minimum = 1;
            progressBar1.Value = 1;

            buttonOK.Enabled = false;

            for (int i = 0; i < activities.Count; i++)
            {
                progressBar1.Value = i + 1;
                textBox1.Text = String.Format(Resources.ExportProgressText, i + 1, activities.Count);
                this.Refresh();
                if (activities[i].GPSRoute != null)
                {
                    if (activities[i].GPSRoute.Count > 0 && activities[i].StartTime < DateTime.Now)
                    {
                        Controller.GetInstance().Export(activities[i], false);
                    }
                }
            }

            buttonOK.Enabled = true;
            progressBar1.Value = activities.Count;
        }

    }
}
